<?php
/**
 * 测试模拟post请求控制器
 */
namespace Api\Controller;
use Think\Controller;
class TestController extends Controller {
    public function index(){
        //用户登录接口参数
        /* $post_data = array(
            'login_name'=>'1111',
            'password'  =>'2222'
        ); 
        $target = 'http://'.$_SERVER['HTTP_HOST'].U('NbApi/nb_login');
        */
        //用户注册接口参数
        $post_data = array(
            'org_id'       =>'5',
            'register_name'=>'gaopan1',
            'register_form'=>'weixin',
            'register_type'=>1,
            'password'     =>'111111',
            're_password'  =>'111111',
            'verify_code'  =>'837594'
        );
        $target = 'http://'.$_SERVER['HTTP_HOST'].U('NbApi/nb_register');
          
        //验证获取邮箱验证码的接口
        /*$post_data = array(
            'email'=>'523350109@qq.com',
        );
        $target = 'http://'.$_SERVER['HTTP_HOST'].U('NbApi/nb_email_verify');
        */
        
        //查询用户信息
        /* $post_data = array(
            'uid'=>'1',
        );
        $target = 'http://'.$_SERVER['HTTP_HOST'].U('NbApi/nb_userinfo');
         */
        
        //修改手机号
       /* $post_data = array(
            'uid'     =>2,
            'phone'=>'18771925960',
            'code'=>'888131'
        );
        $target = 'http://'.$_SERVER['HTTP_HOST'].U('NbApi/nb_update_phone');
          */
        //验证获取手机验证码的接口
        /* $post_data = array(
            'phone'=>'18771925960',
        );
        $target = 'http://'.$_SERVER['HTTP_HOST'].U('NbApi/nb_phone_verify');
         */
        //每20秒上传一次脑波数据
        /* $post_data = array(
            'uid'=>'4',
            'exam_result'=>'[ { "hightbeta" : [ 22995, 3793, 12767, 1386, 5558, 3739, 1245, 18451, 21294, 27813, 6139, 31598, 1925, 15026, 1141 ], "lowbeta" : [ 27206, 4093, 6056, 1289, 3328, 2463, 1067, 5438, 20060, 11399, 2553, 35269, 837, 22735, 1549 ], "lowgamma" : [ 19845, 2120, 1359, 1052, 2506, 6457, 697, 2684, 25553, 17449, 5703, 29280, 793, 19829, 1456 ], "theta" : [ 90807, 52436, 69604, 7406, 55641, 47321, 7662, 80327, 116905, 130401, 182601, 141796, 29108, 146382, 10780 ], "Attention" : [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], "lowalpha" : [ 76947, 11630, 8328, 2760, 6840, 6345, 1525, 7372, 37008, 18896, 6361, 31786, 1568, 5974, 4718 ], "highalpha" : [ 25668, 6936, 6121, 484, 7147, 5797, 758, 11993, 3836, 7898, 5185, 26111, 1325, 22856, 5102 ], "delta" : [ 692543, 514274, 309730, 79394, 1101745, 583805, 66315, 644251, 1367666, 180110, 265407, 498410, 69697, 318489, 240366 ], "index" : 1, "singel" : [ 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200 ], "Meditation" : [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], "highgamma" : [ 9691, 1428, 1941, 517, 1328, 2555, 540, 1960, 9714, 6511, 2547, 8976, 404, 6358, 442 ] } ]'
        );
        $target = 'http://'.$_SERVER['HTTP_HOST'].U('NbApi/nb_upload_EEG_data'); */
         
        /* $post_data = array(
            'uid'=>'4',
        );
        $target = 'http://'.$_SERVER['HTTP_HOST'].U('NbApi/nb_user_EEG_data');
         */
        /* //修改用户信息
         $post_data = array(
         'uid'     =>2,
         'birthday'=>'1990-02-11',
         'nickname'=>'test1',
         'sex'     =>'1'
         );
         $target = 'http://'.$_SERVER['HTTP_HOST'].U('NbApi/nb_userinfo_update');
         */
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $target);
        curl_setopt($curl, CURLOPT_HEADER, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_NOBODY, true);
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
        $return_str = curl_exec($curl); 
        curl_close($curl);
        echo $return_str;
        echo '<pre>';
        print_r(json_decode($return_str,TRUE));
    }
    //上传测试接口
    public function upload(){
        $this->display();
    }
    //echarts测试
    public function echar(){
        $this->display();
    }
}